Skip to content

feat(quickbooks): add procurement integration - #6061

Closed
BillLeoutsakosvl346 wants to merge 19 commits into
stagingfrom
add-quickbooks-procurement
Closed

feat(quickbooks): add procurement integration#6061
BillLeoutsakosvl346 wants to merge 19 commits into
stagingfrom
add-quickbooks-procurement

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • Add QuickBooks Online OAuth support and procurement-focused query tools
  • Add QuickBooks block for vendors, purchase orders, bills, and custom queries
  • Generate integration docs and registry metadata

Type of Change

  • New feature

Testing

  • bun run scripts/generate-docs.ts
  • bun run lint
  • bun run test tools/quickbooks/quickbooks.test.ts lib/oauth/oauth.test.ts
  • bun run type-check
  • bun run check:api-validation:strict
  • bun run check:bare-icons
  • ship audit suite passed

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 30, 2026 2:41pm

Request Review

@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches OAuth and can mutate production accounting data (CRUD, preferences, attachments), but entity validation, token/file checks, and extensive tests reduce exposure; misconfigured realmId or credentials remain the main operational risk.

Overview
Adds QuickBooks Online as an OAuth integration so workflows and agents can work against a company via realmId (from the Intuit OAuth callback).

Auth & platform wiring: Intuit OAuth provider (Basic auth token refresh, OpenID userinfo with sandbox/production fallback), QUICKBOOKS_CLIENT_ID / QUICKBOOKS_CLIENT_SECRET, block/tool registry, docs page, and brand icon.

Capabilities: A QuickBooks workflow block routes 20 operations to matching tools—generic CRUD/list/query, vendors/bills/PO shortcuts, financial reports, preferences and exchange rates, CDC (get_changes), batch (≤10 items), transaction PDF download/send, attachment URL, and file upload. Shared helpers enforce entity allowlists, query/CDC limits, response size caps, and access-token header safety.

Upload path: Attachments use a dedicated POST /api/tools/quickbooks/upload-attachment route (internal auth, tool file access checks, extension/content-type whitelist, 25 MB limit, Intuit multipart field names) instead of a plain client-side tool fetch.

Tests: Broad coverage for utils, tools, block param mapping, OAuth userinfo, and the upload API route.

Reviewed by Cursor Bugbot for commit cbebb5f. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread apps/sim/lib/auth/auth.ts
Comment thread apps/sim/tools/quickbooks/utils.ts Outdated
@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds QuickBooks Online OAuth, a procurement-focused block/tools surface, attachment upload API, docs, and registry metadata.

  • OAuth provider wiring with OpenID userinfo (prod/sandbox fallback) and accounting scope
  • Block + tools for list/CRUD/query/report/CDC/batch/PDF/send/attachments with Company ID and Environment controls
  • Sandbox API host selectable via apiEnvironment (defaults production)
  • Generated docs, icons, env vars, and validation-contract registration

Confidence Score: 5/5

This PR appears safe to merge; prior Greptile threads are resolved or explicitly accepted for v1.

Sandbox host selection is implemented end-to-end with tests, and the realmId/Company ID limitation was accepted as a documented v1 tradeoff with no remaining incomplete fix on that path.

Important Files Changed

Filename Overview
apps/sim/tools/quickbooks/utils.ts URL builders resolve production vs sandbox hosts from apiEnvironment; prior production-only host issue is addressed.
apps/sim/blocks/blocks/quickbooks.ts Adds Environment dropdown and passes apiEnvironment through tool params; Company ID remains required manual input per v1 tradeoff.
apps/sim/lib/auth/auth.ts Registers QuickBooks genericOAuth provider; realmId still not auto-persisted (accepted v1).
apps/sim/app/api/tools/quickbooks/upload-attachment/route.ts Multipart upload route forwards apiEnvironment into QuickBooks upload URL construction.

Sequence Diagram

sequenceDiagram
  participant User
  participant Block as QuickBooks Block
  participant OAuth as Better Auth OAuth
  participant Tool as QuickBooks Tools
  participant QBO as QuickBooks Online API

  User->>OAuth: Connect QuickBooks
  OAuth->>QBO: OAuth2 + userinfo
  OAuth-->>User: Stored credential
  User->>Block: Operation + Company ID + Environment
  Block->>Tool: credential, realmId, apiEnvironment, params
  Tool->>QBO: REST call (prod or sandbox host)
  QBO-->>Tool: JSON / PDF / attachment
  Tool-->>Block: Normalized tool output
Loading

Reviews (13): Last reviewed commit: "fix(quickbooks): close remaining respons..." | Re-trigger Greptile

Comment thread apps/sim/lib/auth/auth.ts
Comment thread apps/sim/tools/quickbooks/utils.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 75579c9. Configure here.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread apps/sim/blocks/blocks/quickbooks.ts Outdated
Comment thread apps/sim/tools/quickbooks/download_document.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread apps/sim/tools/quickbooks/utils.ts
Comment thread apps/sim/app/api/tools/quickbooks/upload-attachment/route.ts
Comment thread apps/sim/app/api/tools/quickbooks/upload-attachment/route.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread apps/sim/tools/quickbooks/utils.ts
Comment thread apps/sim/tools/quickbooks/create_record.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread apps/sim/tools/quickbooks/utils.ts
Comment thread apps/sim/lib/oauth/quickbooks.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit db63eba. Configure here.

Comment thread apps/sim/app/api/tools/quickbooks/upload-attachment/route.ts
Comment thread apps/sim/lib/api/contracts/tools/quickbooks.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread apps/sim/lib/api/contracts/tools/quickbooks.ts Outdated
Comment thread apps/sim/tools/quickbooks/types.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread apps/sim/lib/api/contracts/tools/quickbooks.ts Outdated
Comment thread apps/sim/tools/quickbooks/run_report.ts
throw new Error(
`QuickBooks does not support ${normalizedContentType} content for .${extension} attachments`
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Octet stream blocks PDF uploads

Medium Severity

validateQuickBooksAttachmentFile rejects uploads when the resolved MIME is application/octet-stream, because that type is not on the per-extension whitelist. Many PDFs (and other allowed types) arrive with that generic type from the browser or from downloadServableFileFromStorage, which keeps userFile.type when set and does not treat octet-stream as “unknown” and infer from the filename. Valid attachments can fail validation before Intuit is called.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cbebb5f. Configure here.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cbebb5f. Configure here.

function normalizeMinorVersion(value?: string): string {
const trimmed = value?.trim()
return trimmed || QUICKBOOKS_MINOR_VERSION
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid minor version accepted

Low Severity

normalizeMinorVersion forwards any non-empty trimmed string into minorversion query params for direct Accounting tools, while the upload route contract requires one to five digits. A typo like abc in advanced Minor Version is not rejected before the Intuit request.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cbebb5f. Configure here.

@BillLeoutsakosvl346
BillLeoutsakosvl346 deleted the add-quickbooks-procurement branch July 30, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant